package com.examples.springboot.jpa.gui;

import java.awt.BorderLayout;
import java.beans.PropertyChangeListener;

import javax.annotation.PostConstruct;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.examples.springboot.jpa.ExampleDataCreator;
import com.examples.springboot.jpa.gui.department.EmployeeListView;
import com.examples.springboot.jpa.resources.DepartmentResource;
import com.examples.springboot.jpa.resources.EmployeeResource;

@Controller
@SuppressWarnings("serial")
public class ContentView  extends JPanel{
  @Autowired
  private ExampleDataCreator mDataCreator;

  @Autowired
  public ContentView(EmployeeResource employeeResource,DepartmentResource departmentResource) {
    super(new BorderLayout());

  //Create the components.
    JPanel frequentPanel = new EmployeeListView(employeeResource,departmentResource);
//    JPanel featurePanel = createFeatureDialogBox();
    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("Simple Climber Dialogs", null,
                      frequentPanel,
                      "Some simple dialogs");

    add(tabbedPane, BorderLayout.CENTER);
    addPropertyChangeListener("postInit", (PropertyChangeListener)frequentPanel);
  }

  @PostConstruct
  private void init() {
    mDataCreator.createClimbers();
    mDataCreator.createEmployees();
    firePropertyChange("postInit", 0, 1);
  }
  
  /** Creates the panel shown by the first tab. */
//  private JPanel climbersTableViewCreate() {
//    
//  }
  
//  /** Creates the panel shown by the second tab. */
//  private JPanel createFeatureDialogBox() {
//    
//  }
}
